'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-29 19:30:09
'''
#
# @lc app=leetcode.cn id=976 lang=python3
#
# [976] 三角形的最大周长
#

# @lc code=start
from typing import List
class Solution:
    def largestPerimeter(self, A: List[int]) -> int:
        A.sort(reverse=True)
        for i in range(len(A)-2):
            if A[i]<A[i+1]+A[i+2]:
                return sum(A[i:i+3])
        return 0
        
# @lc code=end

